import { IsEmail, IsNotEmpty, MinLength, Matches, IsOptional } from 'class-validator';

export class CreateUserDto {
    @IsNotEmpty({ message: '用户名不能为空' })
    @Matches(/^[a-zA-Z0-9_]{4,20}$/, { message: '用户名只能包含字母、数字和下划线，长度为4-20个字符' })
    username: string;

    @IsNotEmpty({ message: '邮箱不能为空' })
    @IsEmail({}, { message: '请输入有效的邮箱地址' })
    email: string;

    @IsNotEmpty({ message: '密码不能为空' })
    @MinLength(8, { message: '密码长度不能少于8个字符' })
    @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+]{8,}$/, {
        message: '密码需包含至少一个大写字母、一个小写字母和一个数字',
    })
    password: string;

    @IsOptional()
    nickname: string;

    @IsOptional()
    avatar: string;

    @IsOptional()
    bio: string;
} 